home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
glass
/
glass.lha
/
GLASS
/
dtm
/
test4.gl
< prev
next >
Wrap
Text File
|
1991-06-18
|
699b
|
37 lines
Basetype E;
Atom
not :- E => E,
nand2 :- E & E => E,
adc :- E & E & E => E & E,
div2 :- E => E;
Def
sel :- E & E & E => E;
sel [s, a, b] = nand2 [nand2 [not s, a], nand2 [s, b]];
Mac
divchain :- Int -> E => E -> E => E;
divchain 0 A in = in;
divchain n A in = divchain (n-1) A (A in);
Def
div1024 :- E => E;
div1024 in = divchain 10 div2 in;
Mac
adder :- Int -: n -> E^n & E^n & E => E & E^n;
adder 0 [[],[],c] = [c,[]];
adder n [a:as, b:bs, c] = [cout, s:ss]
where
[v,s] = adc [a,b,c];
[cout,ss] = adder (n-1) [as, bs, v];
endwhere;
Def
adder4 :- E^4 & E^4 & E => E & E^4;
adder4 [as,bs,c] = adder 4 [as,bs,c];